home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / C64 / M-More Monthly Disks / (c)m4.d64 / synth sound.c (.txt) < prev    next >
Commodore BASIC  |  2007-02-04  |  8KB  |  303 lines

  1. 1 REM SYNTH SOUND
  2. 2 REM ** WRITTEN BY S,A,WATSON **
  3. 3 AD=12:SR=12:W=33:HP=0:LP=0:POKE54296,15
  4. 4 GOSUB1000:GOSUB3000
  5. 6 REM *****************
  6. 7 REM * VOICE ROUTINE *
  7. 8 REM *****************
  8. 9 REM
  9. 10 GETK$:IFK$=""THEN10
  10. 11 GOSUB100
  11. 12 IFK$=""THEN10
  12. 13 POKE54276,0
  13. 14 POKE54277,AD
  14. 15 POKE54278,SR
  15. 16 POKE54275,HP:POKE54274,LP
  16. 17 POKE54276,W
  17. 18 POKE54273,A:POKE54272,B
  18. 20 GETK$:IFK$=""THEN20
  19. 21 GOSUB100
  20. 22 IFK$=""THEN20
  21. 23 POKE54283,0
  22. 24 POKE54284,AD
  23. 25 POKE54285,SR
  24. 26 POKE54282,HP:POKE54281,LP
  25. 27 POKE54283,W
  26. 28 POKE54280,A:POKE54279,B
  27. 30 GETK$:IFK$=""THEN30
  28. 31 GOSUB100
  29. 32 IFK$=""THEN30
  30. 33 POKE54290,0
  31. 34 POKE54291,AD
  32. 35 POKE54292,SR
  33. 36 POKE54289,HP:POKE54288,LP
  34. 37 POKE54290,W
  35. 38 POKE54287,A:POKE54286,B
  36. 39 GOTO10
  37. 40 REM
  38. 41 REM ******************
  39. 42 REM * OCTAVE 1 TABLE *
  40. 43 REM ******************
  41. 44 REM
  42. 100 IFO=2THEN200
  43. 101 IFO=3THEN300
  44. 102 IFO=4THEN400
  45. 103 IFK$=""THENPOKE54276,0:POKE54283,0:POKE54290,0:K$="":RETURN
  46. 105 IFK$="2"THENO=2:K$="":RETURN
  47. 106 IFK$="3"THENO=3:K$="":RETURN
  48. 107 IFK$="4"THENO=4:K$="":RETURN
  49. 112 IFK$="Z"THENA=28:B=214:RETURN
  50. 113 IFK$="X"THENA=32:B=94:RETURN
  51. 114 IFK$="C"THENA=34:B=75:RETURN
  52. 115 IFK$="V"THENA=38:B=126:RETURN
  53. 125 IFK$="B"THENA=43:B=52:RETURN
  54. 130 IFK$="N"THENA=45:B=198:RETURN
  55. 135 IFK$="M"THENA=51:B=97:RETURN
  56. 140 IFK$=","THENA=57:B=172:RETURN
  57. 145 IFK$="."THENA=64:B=188:RETURN
  58. 150 IFK$="/"THENA=68:B=149:RETURN
  59. 151 REM
  60. 152 REM       ** SHARPS **
  61. 153 REM
  62. 154 IFK$="S"THENA=30:B=141:RETURN
  63. 155 IFK$="F"THENA=36:B=85:RETURN
  64. 160 IFK$="G"THENA=40:B=200:RETURN
  65. 161 IFK$="J"THENA=48:B=127:RETURN
  66. 165 IFK$="K"THENA=54:B=111:RETURN
  67. 170 IFK$="L"THENA=61:B=126:RETURN
  68. 175 IFK$=";"THENA=42:B=169:RETURN
  69. 189 IFK$="_"THENGOSUB650
  70. 190 IFK$="\"THENGOSUB600
  71. 191 IFK$="[133]"THENW=33:K$="":RETURN
  72. 192 IFK$="[134]"THENW=17:K$="":RETURN
  73. 193 IFK$="[135]"THENW=129:K$="":RETURN
  74. 194 IFK$="[136]"THENW=65:K$="":RETURN
  75. 195 IFK$=""THENRETURN
  76. 196 REM
  77. 197 REM ******************
  78. 198 REM * OCTAVE 2 TABLE *
  79. 199 REM ******************
  80. 200 IFK$=""THENPOKE54276,0:POKE54283,0:POKE54290,0:K$="":RETURN
  81. 201 IFK$="1"THENO=1:K$="":RETURN
  82. 202 IFK$="3"THENO=3:K$="":RETURN
  83. 203 IFK$="4"THENO=4:K$="":RETURN
  84. 212 IFK$="Z"THENA=14:B=107:RETURN
  85. 213 IFK$="X"THENA=16:B=47:RETURN
  86. 214 IFK$="C"THENA=17:B=37:RETURN
  87. 215 IFK$="V"THENA=19:B=63:RETURN
  88. 225 IFK$="B"THENA=21:B=154:RETURN
  89. 230 IFK$="N"THENA=22:B=227:RETURN
  90. 235 IFK$="M"THENA=25:B=177:RETURN
  91. 240 IFK$=","THENA=28:B=214:RETURN
  92. 245 IFK$="."THENA=32:B=94:RETURN
  93. 250 IFK$="/"THENA=34:B=75:RETURN
  94. 251 REM
  95. 252 REM       ** SHARPS **
  96. 253 REM
  97. 254 IFK$="S"THENA=15:B=70:RETURN
  98. 255 IFK$="F"THENA=18:B=42:RETURN
  99. 260 IFK$="G"THENA=20:B=100:RETURN
  100. 261 IFK$="J"THENA=24:B=63:RETURN
  101. 265 IFK$="K"THENA=27:B=56:RETURN
  102. 270 IFK$="L"THENA=30:B=141:RETURN
  103. 275 IFK$=";"THENA=36:B=85:RETURN
  104. 289 IFK$="_"THENGOSUB650
  105. 290 IFK$="\"THENGOSUB600
  106. 291 IFK$="[133]"THENW=33:K$="":RETURN
  107. 292 IFK$="[134]"THENW=17:K$="":RETURN
  108. 293 IFK$="[135]"THENW=129:K$="":RETURN
  109. 294 IFK$="[136]"THENW=65:K$="":RETURN
  110. 295 IFK$=""THENRETURN
  111. 296 REM
  112. 297 REM ******************
  113. 298 REM * OCTAVE 3 TABLE *
  114. 299 REM ******************
  115. 300 IFK$=""THENPOKE54276,0:POKE54283,0:POKE54290,0:K$="":RETURN
  116. 301 IFK$="1"THENO=1:K$="":RETURN
  117. 302 IFK$="2"THENO=2:K$="":RETURN
  118. 303 IFK$="4"THENO=4:K$="":RETURN
  119. 312 IFK$="Z"THENA=7:B=53:RETURN
  120. 313 IFK$="X"THENA=8:B=23:RETURN
  121. 314 IFK$="C"THENA=8:B=147:RETURN
  122. 315 IFK$="V"THENA=9:B=159:RETURN
  123. 325 IFK$="B"THENA=10:B=205:RETURN
  124. 330 IFK$="N"THENA=11:B=114:RETURN
  125. 335 IFK$="M"THENA=12:B=216:RETURN
  126. 340 IFK$=","THENA=14:B=107:RETURN
  127. 345 IFK$="."THENA=16:B=47:RETURN
  128. 350 IFK$="/"THENA=17:B=37:RETURN
  129. 351 REM
  130. 352 REM       ** SHARPS **
  131. 353 REM
  132. 354 IFK$="S"THENA=7:B=163:RETURN
  133. 355 IFK$="F"THENA=9:B=21:RETURN
  134. 360 IFK$="G"THENA=10:B=60:RETURN
  135. 361 IFK$="J"THENA=12:B=32:RETURN
  136. 365 IFK$="K"THENA=13:B=156:RETURN
  137. 370 IFK$="L"THENA=15:B=70:RETURN
  138. 375 IFK$=";"THENA=18:B=42:RETURN
  139. 389 IFK$="_"THENGOSUB650
  140. 390 IFK$="\"THENGOSUB600
  141. 391 IFK$="[133]"THENW=33:K$="":RETURN
  142. 392 IFK$="[134]"THENW=17:K$="":RETURN
  143. 393 IFK$="[135]"THENW=129:K$="":RETURN
  144. 394 IFK$="[136]"THENW=65:K$="":RETURN
  145. 395 IFK$=""THENRETURN
  146. 396 REM
  147. 397 REM ******************
  148. 398 REM * OCTAVE 4 TABLE *
  149. 399 REM ******************
  150. 400 IFK$=""THENPOKE54276,0:POKE54283,0:POKE54290,0:K$="":RETURN
  151. 401 IFK$="1"THENO=1:K$="":RETURN
  152. 402 IFK$="2"THENO=2:K$="":RETURN
  153. 403 IFK$="3"THENO=3:K$="":RETURN
  154. 412 IFK$="Z"THENA=3:B=155:RETURN
  155. 413 IFK$="X"THENA=4:B=12:RETURN
  156. 414 IFK$="C"THENA=4:B=73:RETURN
  157. 415 IFK$="V"THENA=4:B=208:RETURN
  158. 425 IFK$="B"THENA=5:B=103:RETURN
  159. 430 IFK$="N"THENA=5:B=185:RETURN
  160. 435 IFK$="M"THENA=6:B=108:RETURN
  161. 440 IFK$=","THENA=7:B=53:RETURN
  162. 445 IFK$="."THENA=8:B=23:RETURN
  163. 450 IFK$="/"THENA=8:B=147:RETURN
  164. 451 REM
  165. 452 REM       ** SHARPS **
  166. 453 REM
  167. 454 IFK$="S"THENA=3:B=210:RETURN
  168. 455 IFK$="F"THENA=4:B=139:RETURN
  169. 460 IFK$="G"THENA=5:B=25:RETURN
  170. 461 IFK$="J"THENA=6:B=16:RETURN
  171. 465 IFK$="K"THENA=6:B=206:RETURN
  172. 470 IFK$="L"THENA=7:B=163:RETURN
  173. 475 IFK$=";"THENA=9:B=21:RETURN
  174. 489 IFK$="_"THENGOSUB650
  175. 490 IFK$="\"THENGOSUB600
  176. 491 IFK$="[133]"THENW=33:K$="":RETURN
  177. 492 IFK$="[134]"THENW=17:K$="":RETURN
  178. 493 IFK$="[135]"THENW=129:K$="":RETURN
  179. 494 IFK$="[136]"THENW=65:K$="":RETURN
  180. 495 IFK$=""THENRETURN
  181. 496 RETURN
  182. 594 REM
  183. 595 REM ****************************
  184. 596 REM * INSTRUMENT CHANG ROUTINE *
  185. 597 REM ****************************
  186. 600 REM
  187. 602 PRINT"";TAB(34);"[\]"
  188. 605 GETQ$:IFQ$=""THEN605
  189. 608 PRINT"";TAB(34);"   "
  190. 610 IFQ$="+"THENAD=12:SR=12:W=33:HP=0:LP=0:K$="":RETURN
  191. 620 IFQ$="-"THENAD=9:SR=0:W=65:HP=2:LP=255:K$="":RETURN
  192. 630 IFQ$="@"THENAD=24:SR=15:W=17:HP=0:LP=0:K$="":RETURN
  193. 640 IFQ$="*"THENAD=135:SR=15:W=17:HP=0:LP=0:K$="":RETURN
  194. 641 RETURN
  195. 642 REM
  196. 643 REM *******************************
  197. 644 REM * DEFINABLE INSTRUMENT CHANGE *
  198. 645 REM *******************************
  199. 650 PRINT"[_]"
  200. 651 GETX$:IFX$=""THEN651
  201. 652 PRINT"   "
  202. 655 IFX$="9"THENGOSUB800
  203. 660 IFX$>"8"ORX$<"1"THENRETURN
  204. 662 X=VAL(X$)
  205. 670 AD=AD(X):SR=SR(X):HP=HP(X):LP=LP(X):W=W(X)
  206. 671 K$="":RETURN
  207. 800 PRINT"[147][215]HAT [201]NSTRUMENT DO YOU WISH TO EXAMINE"
  208. 810 INPUT"             1 TO 8 ";DE
  209. 820 IFDE>8ORDE<1THENPRINT"[145][145][145]":GOTO810
  210. 830 PRINT"[147][212]HE [201]NSTRUMENT YOU WISH TO EXAMINE IS:-"
  211. 840 PRINT"              ";IN$(DE)
  212. 850 PRINT"[201]TS SETTINGS ARE AS FOLLOWS:-"
  213. 860 PRINT"        [176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][178][192][192][192][192][192][174]"
  214. 870 PRINT"        [221][159][193]TTACK/[196]ECAY    [221][159]";AD(DE);TAB(31);"[221]"
  215. 871 PRINT"        [171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][179]"
  216. 872 PRINT"        [221][159][211]USTAIN/[210]ELEASE [221][159]";SR(DE);TAB(31);"[221]"
  217. 873 PRINT"        [171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][179]"
  218. 874 PRINT"        [221][159][215]AVEFORM        [221][159]";W(DE);TAB(31);"[221]"
  219. 875 PRINT"        [171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][179]"
  220. 876 PRINT"        [221][159][200]IGH [208]ULSE RATE [221][159]";HP(DE);TAB(31);"[221]"
  221. 877 PRINT"        [171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][179]"
  222. 878 PRINT"        [221][159][204]OW  [208]ULSE RATE [221][159]";LP(DE);TAB(31);"[221]"
  223. 879 PRINT"        [173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][177][192][192][192][192][192][189]"
  224. 880 INPUT"     [196]O YOU WISH TO REDIFINE([217]/[206])[159]";T$
  225. 885 IFT$="Y"THENPRINT"":GOSUB2010
  226. 886 IFT$="N"THEN895
  227. 887 PRINT"[145][145]":GOTO880
  228. 895 GOSUB3000
  229. 900 RETURN
  230. 990 REM
  231. 991 REM ************************
  232. 992 REM * PROGRAM INTRODUCTION *
  233. 993 REM ************************
  234. 998 REM
  235. 1000 POKE53280,0:POKE53281,0
  236. 1010 PRINT"[147]          [200]ELLO AND WELCOME TO"
  237. 1020 PRINT"[160]            [211][217][206][212][200][197][211][207][213][206][196] 64 "
  238. 1030 PRINT"[215]ITH THIS PROGRAM, YOU CAN PLAY ANY ONE"
  239. 1040 PRINT"OF FOUR OCTAVES. [217]OU CAN CHANGE OCTAVES"
  240. 1050 PRINT"AT  ANY  TIME  WHILE  YOU'RE PLAYING BY"
  241. 1060 PRINT"PRESSING  KEYS [159] 1, 2, 3 OR 4. [212]HERE ARE"
  242. 1070 PRINT"ALSO  TWELVE SETS OF SOUNDS THAT CAN BE"
  243. 1080 PRINT"USED. [197]IGHT OF THESE ARE USER DEFINABLE"
  244. 1090 PRINT"AND CAN  BE SET  UP AT THE START OF THE"
  245. 1100 PRINT"PROGRAM, OR REDEFINED WHILE THE PROGRAM"
  246. 1110 PRINT"IS RUNNING  BY  PRESSING  KEY '_' & '9'"
  247. 1120 INPUT"      [197]NTER '[207][195][212][193][214][197]' 1 TO 4 ";O
  248. 1125 PRINT""
  249. 1130 IFO>4ORO<1THENPRINT"[145][145][145]":GOTO1120
  250. 1140 RETURN
  251. 2000 REM
  252. 2001 REM **************************
  253. 2002 REM * DEFINABLE INST' SET UP *
  254. 2003 REM **************************
  255. 2004 REM
  256. 2010 PRINT"[145][145][145][145][145][145][145][145][145][145][145]   [197]NTER NAME FOR INSTRUMENT NUMBER ";DE
  257. 2020 INPUT"            ";IN$(DE)
  258. 2030 INPUT"[197]NTER [193]TTACK/[196]ECAY LEVEL(0-255)";AD(DE)
  259. 2035 IFAD(DE)>255ORAD(DE)<0THENPRINT"[211]ORRY ";AD(DE);" IS OUT OF RANGE":GOTO2030
  260. 2040 INPUT"[197]NTER [211]USTAIN/[210]ELEASE LEVEL(0-255)";SR(DE)
  261. 2045 IFSR(DE)>255ORSR(DE)<0THENPRINT"[211]ORRY ";SR(DE);" IS OUT OF RANGE":GOTO2040
  262. 2050 INPUT"[197]NTER WAVEFORM [210]EQUIRED ([211]-[212]-[206] OR [208])";W$(DE)
  263. 2060 IFW$(DE)="T"THENW(DE)=17:GOTO2990
  264. 2065 IFW$(DE)="S"THENW(DE)=33:GOTO2990
  265. 2070 IFW$(DE)="N"THENW(DE)=129:GOTO2990
  266. 2075 IFW$(DE)="P"THENW(DE)=65:GOTO2100
  267. 2080 PRINT"[211]ORRY ";W$(DE);" NOT UNDERSTOOD":GOTO2050
  268. 2100 INPUT"[197]NTER THE [200][201] PULSE RATE(0-15)";HP(DE)
  269. 2110 IFHP(DE)<0THENPRINT"[211]ORRY, PULSE RATE TOO [204][207][215]":GOTO2100
  270. 2120 IFHP(DE)>15THENPRINT"[211]ORRY, PULSE RATE TOO [200][201][199][200]":GOTO2100
  271. 2130 INPUT"[197]NTER THE [204][207] PULSE RATE(0-15)";LP(DE)
  272. 2140 IFLP(DE)<0THENPRINT"[211]ORRY, PULSE RATE TOO [204][207][207]":GOTO2130
  273. 2150 IFLP(DE)>15THENPRINT"[211]ORRY, PULSE RATE TOO [200][201][199][200]":GOTO2130
  274. 2990 RETURN
  275. 3000 PRINT"[147]                               "
  276. 3010 PRINT"          [146]  [221]   [221]    [221]  "
  277. 3020 PRINT"          [146]  [221]   [221]    [221]  "
  278. 3030 PRINT"          [146]  [221]   [221]    [221]  "
  279. 3040 PRINT"          [146] [221] [221] [221] [221] [221] [221] [221] [221] [221] [221] "
  280. 3050 PRINT"          [146][218][221][216][221][195][221][214][221][194][221][206][221][205][221],[221].[221]/[221] "
  281. 3060 PRINT"[176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][178][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][174]"
  282. 3100 PRINT"[221][159][201][206][211][212][210][213][205][197][206][212]  [203][197][217][211]  [221][159]   [207][195][212][193][214][197]   [203][197][217]   [221]"
  283. 3105 PRINT"[171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][219][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][179]"
  284. 3110 PRINT"[221][159][208]IANO        \ +  [221][159]   [198]IRST     1    [221]"
  285. 3120 PRINT"[221][159][194]ANJO        \ -  [221][159]   [211]ECOND    2    [221]"
  286. 3130 PRINT"[221][159][216]YLOPHONE    \ @  [221][159]   [212]HIRD     3    [221]"
  287. 3140 PRINT"[221][159][215]OODWIND     \ *  [221][159]   [198]OURTH    4    [221]"
  288. 3160 FORI=1TO8
  289. 3165 IFIN$(I)=""THENIN$(I)="[206]OT [213]SED"
  290. 3170 PRINT"[221][159]";IN$(I);TAB(14);"_";I;TAB(19);"[221]";TAB(38);"[221]"
  291. 3180 NEXTI
  292. 3190 PRINT"[173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][177][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][189]"
  293. 3200 PRINT"[145][145][145][145][145][145][145][145][145]"
  294. 3210 PRINTTAB(19)"[171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][179]"
  295. 3220 PRINTTAB(19)"[221][159] [215][193][214][197][198][207][210][205]   [203][197][217]   [221]"
  296. 3230 PRINTTAB(19)"[171][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][179]"
  297. 3240 PRINTTAB(21)"[159][211]AWTOOTH     F1"
  298. 3250 PRINTTAB(21)"[212]RIANGLE     F3"
  299. 3260 PRINTTAB(21)"[206]OISE        F5"
  300. 3270 PRINTTAB(21)"[208]ULSE        F7"
  301. 3280 PRINT"    [208]RESS '[158]_[159]' THEN '[158]9[159]' TO RE-DEFINE."
  302. 3400 RETURN
  303.